Quiz I: 
Date: Tuesday, February 10
Material: Chapter 1 + Chapter 2 (Up to and including Scanner class)
Where: during class time

Coding + MCQ + TF

- Chapter 3: 

Scanner: interactive program + it is part of java.util
Scanner scan = new Scanner(System.in);
Instantiation statement: It is creating an object called scan as an instance of 
the class called Scanner. This vocabulary applies only to class data types. 

scan.nextLine();

nextLine(): should be preceded with an object + a dot

1st Scanner: is the class name
2nd Scanner(: constructor method

a vs a()

System.out.println();

- primitive data types as opposed to class data types:

int val = 12;
val: 12

val is a primitive variable (its data type is one of the 8 primitive data types)

String str = new String("Iron Man");

str: addr1 ----> addr1: Iron Man

str is called an object reference variable

YAGNI (You Ain't Gonna Need It)

int length(): signature of the method

Example#1: StringDemo.java 

- Effect of assignment on objects:

int val1 = 5, val2 = 6;

val1 = val2;

System.out.println("val1: " + val1); // val1: 6
System.out.println("val2: " + val2); // val2: 6

val1: 5, val2: 6
val1: 6, val2: 6
Two different locations in the memory with the same value

String str1 = "Iron Man";
String str2 = "James Bond";

str1: add1 ---> "Iron Man"
str2: add2 ---> "James Bond"


str1 = str2;

str1 ----> "James Bond" <--- str2
System.gc(); // Force garbage collection

System.out.println(str1.length()); // 10
System.out.println(str2.length()); // 10

- String class
charAt
concat
length
substring
toLowerCase
toUpperCase
equals
equalsIgnoreCase
compareTo
replace
indexOf	
trim

Aside:

'a' + 'b' ---> 195
"" + 'a' + 'b' ---> "ab"

Wissam Fawaz
































